<?php

namespace app\admin\model;

use think\Model;

class Adminwork extends Model
{
    // 表名
    protected $name = 'adminwork';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'statuslist_text'
    ];
    

    
    public function getStatuslistList()
    {
        return ['1' => __('Statuslist 1'),'2' => __('Statuslist 2'),'3' => __('Statuslist 3'),'4' => __('Statuslist 4')];
    }     
    public function getQiList(){
        return ['1' => __('Qilist 1'),'2' => __('Qilist 2')];
    }

    public function getStatuslistTextAttr($value, $data)
    {        
        $value = $value ? $value : (isset($data['statuslist']) ? $data['statuslist'] : '');
        $list = $this->getStatuslistList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function admin()
    {
        return $this->belongsTo('Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
